﻿Shader "TouchTable/BaseLineShader"
{
    Properties
    {
        [NoScaleOffset]
        _MainTex ("Texture", 2D) = "white" {}
        //X轴扫描线
		_ScanlinesScaleX("Scanlines Scale X", Float) = 30
		//X轴扫描线速度
		_ScanlinesSpeedX("Scanlines Speed X", Float) = -5
    }
    SubShader
    {
        Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" "PreviewType"="Plane" }
        ZWrite Off Cull Off
        Blend SrcAlpha OneMinusSrcAlpha

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            sampler2D _MainTex;
            float _ScanlinesScaleX;
            float _ScanlinesSpeedX;

            struct appdata
            {
                float4 vertex : POSITION;
                float4 color : COLOR;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                fixed4 color : COLOR;
                float4 vertex : SV_POSITION;
            };

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.color = v.color;
                o.uv = v.uv;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 mainTex = tex2D(_MainTex, i.uv);

				float scanLinesXTime = _Time.y * _ScanlinesSpeedX;
				float scanLinesXClamp = clamp(sin((scanLinesXTime + i.uv.x * _ScanlinesScaleX)) * 1.5f,0.3,1.5f);

                mainTex.a = saturate(mainTex.a);
                return mainTex * scanLinesXClamp * i.color;
            }
            ENDCG
        }
    }
}
